﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace VSLT_Reporting.Dialog_Boxes
{
    /// <summary>
    /// Interaction logic for AppConfigConfirmation.xaml
    /// </summary>
    public partial class AppConfigConfirmation : Window
    {
        private const string strMessage = @"
This program will make some changes to your Visual Studio Load Test Results Database. None of these changes will impact the data currently stored in the DB, nor will it impact any of the functionality of the DB. However, it is recommended that you keep regular backups of your data (regardless of whether you use this program). For a full list of the changes that are made, please see the documentation included with the application.

If you wish to continue, please click OK below. The application will then connect to the database, make the necessary updates and then build a few summary tables of data. Depending on the current size of your database, this operation can take a while. The application will execute this on a background thread which will allow you to read through the help file. When the updates are done, the 'Get All Runs' and 'Get Runs Filtered' will be enabled, and you can start using the application.

-------------------------------------------------------------------------------------
NOTE: Your current Database Connection String is:

    '{0}'

If this is not the correct string, choose Cancel, close the application and edit the VSLT Reporting.exe.config file to set the correct connection string. 
-------------------------------------------------------------------------------------

Please note that this program will check your database every time it is started to see if the version of the additional code is the same as the version of this program. It will also execute a couple of Update stored procedures to ensure the extra Summary tables are up to date. These stored procedures will also execute every time you click on the 'Get All Runs' and 'Get Runs Filtered' buttons. This is to ensure that any new test runs that got stored have been added to the summary tables.
";

        public string sqlConn = "";
        public bool doNotShowAgain = true;
        public bool userClickedOK = false;

        public AppConfigConfirmation()
        {
            InitializeComponent();
        }

        private void btnOK_Click(object sender, RoutedEventArgs e)
        {
            doNotShowAgain = (bool)cbDoNotShowAgain.IsChecked;
            userClickedOK = true;
            this.Close();
        }

        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            doNotShowAgain = false; // Hard Coded to ensure this will show if the user cancels the dialog
            userClickedOK = false;
            this.Close();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            tbText.Text = String.Format(strMessage, sqlConn);
        }
    }
}
